public class testCreateOderItemInventoryCompetitor  {

    static testMethod void testCreateOderItemInventoryCompetitor () {
    VisitAndOrderInProcess__c  Avisit = new VisitAndOrderInProcess__c();
    Distributor__c d = [Select id From Distributor__c limit 1];
    Account acc = [Select id From Account limit 1];
    
    Routing_Plan_And_Visit__c tr=new Routing_Plan_And_Visit__c(Visit_Date__c=Date.today());
            insert tr;
    
                In_Store_Visit__c vi=new In_Store_Visit__c();
            vi.RoutingPlanAndVisit__c=tr.Id;
            vi.OutletName_del__c=acc.Id;
            vi.Start_Time__c=DateTime.newInstance(date.today().year(),date.today().month(),date.today().day(),12,12,12);
            vi.End_Time__c=DateTime.newInstance(date.today().year(),date.today().month(),date.today().day(),22,22,22);
            vi.Main_Shelf_Facing__c=22;
            insert vi;
    
    
             Avisit.OutletAddress__c = 'a';
            Avisit.Distributor__c = d.id;
            Avisit.OrderType__c = '常规';
            Avisit.OutletContact__c = 'a';
            Avisit.OrderDate__c = date.today();
           Avisit .DeliveryDate__c= date.today();
           Avisit .OutletPhone__c='1324123434';
            Avisit.Outlet__c = acc.id;
           Avisit.OutletZipCode__c='adsfasdf';
          Avisit.InStoreVisit__c = vi.id;
          Avisit.Type__c = 'In Store Visit';
          Avisit.StartTime__c = datetime.now();
          insert Avisit;
    
    VisitAndOrderInProcess__c  Ovisit = new VisitAndOrderInProcess__c();
             Ovisit.OutletAddress__c = 'a';
            Ovisit.Distributor__c = d.id;
            Ovisit.OrderType__c = '常规';
            Ovisit.StartTime__c = datetime.now();
            Ovisit.OutletContact__c = 'a';
            Ovisit.OrderDate__c = date.today();
           Avisit .DeliveryDate__c= date.today()+1;
           Ovisit.OutletPhone__c='1324123434';
            Ovisit.Outlet__c = acc.id;
           Ovisit.OutletZipCode__c='adsfasdf';
          Ovisit.InStoreVisit__c = vi.id;
          Ovisit.Type__c = 'Order';
        insert Ovisit ;
    
    
        VisitAndOrderDetailsInProcess__c newVisit = new VisitAndOrderDetailsInProcess__c();
        newVisit.Type__c = 'OrderItem';
       Product2 p = [Select id From Product2 limit 1];
        newVisit.RealItemNumber__c = 5;
        newVisit .RealPackage__c = '5';
        newVisit .ReturnReason__c = '5';
        newVisit .ReturnReasonList__c = '凹罐/破损';
        newVisit .Package__c = '5';
        newVisit .Product__c = p.id;
        newVisit .OrderNumber__c = 5;
        newVisit.Parent__c = Ovisit.id;
        insert newVisit ;
        
        VisitAndOrderDetailsInProcess__c newVisit1 = new VisitAndOrderDetailsInProcess__c();
        newVisit1.Type__c = 'Competitor';
        newVisit1.CompetitorDisplay__c = 5;
        newVisit1 .CompetitorBrand__c = '惠氏';
        newVisit1.Parent__c = Avisit.id;
        insert newVisit1 ;
                
        VisitAndOrderDetailsInProcess__c newVisit2 = new VisitAndOrderDetailsInProcess__c();
        newVisit2.Type__c = 'Inventory';
        newVisit2.GreaterThan6Months__c= 5;
        newVisit2 .Inventory__c = 5;
        newVisit2 .MJNDisplay__c = 5;
        newVisit2 .Product__c = p.id;
        newVisit2 .RetailPrice__c = 5;
        newVisit2.Parent__c = Avisit.id;
        insert newVisit2 ;        

    }
}